package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.admin.stat.GoodsStatsVo;
import com.cskaoyan.bean.vo.admin.stat.OrdersVo;
import com.cskaoyan.bean.vo.admin.stat.UsersVo;
import com.cskaoyan.service.admin.StatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * /**
 *
 * @author 徐宇航
 * @function 统计报表
 * @since 2022/11/20 23:46
 */
@RestController
@RequestMapping("admin/stat")
public class StatController {
    @Autowired
    StatService statService;
    @RequestMapping("user")
    public BaseRespVo queryUsres() {
        List<Map> rows = statService.stateUsers();
        String[] columns = new String[]{"day", "users"};
        UsersVo usersVo = new UsersVo();
       usersVo.setColumns(columns);
        usersVo.setRows(rows);
        return BaseRespVo.ok(usersVo);
    }
    // 订单统计
    @GetMapping("order")
    public BaseRespVo<OrdersVo> stateOrder(){
        OrdersVo ordersVo=statService.stateOrder();
        return BaseRespVo.ok(ordersVo);
    }
    // 商品统计
    @GetMapping("goods")
    public BaseRespVo<GoodsStatsVo> stateGoods(){
        GoodsStatsVo goodsStatsVo=statService.stateGoods();
       return BaseRespVo.ok(goodsStatsVo);
    }
}
